<script lang="ts" setup>
import { computed } from 'vue';
import { userInfo } from "/stores/user";

const mobile = computed(() => userInfo.value.teacherPhone?.replace(/(\d{3})\d{4}(\d{4})/, '$1 **** $2') || '--');
const gender = computed(() => {
	return {
		1: '男',
		0: '女',
	}[userInfo.value.gender] || '--';
})
const email = computed(() => {
	return userInfo.value.teacherEmail?.replace(/(.{2}).+(@.+)/, '$1 **** $2') || '--';
});
</script>

<template>
	<view class="T_page">
		<view class="face">
			<text>头像</text>
			<image src="/static/svg/avatar-default.svg" />
		</view>
		<view class="list">
			<view>
				<text>姓名</text>
				<view>{{ userInfo.teacherName || '--' }}</view>
			</view>
			<view>
				<text>性别</text>
				<view>{{ gender }}</view>
			</view>
			<view>
				<text>手机号</text>
				<view>{{ mobile }}</view>
			</view>
			<view>
				<text>邮箱</text>
				<view>{{ email }}</view>
			</view>
		</view>
		<button class="btn" type="primary" @click="uni.navigateTo({ url: '/pages/editInfo/index' })">编辑</button>
	</view>
</template>

<style lang="scss" scoped>
.T_page {
	display: flex;
	flex-direction: column;

	>.face {
		margin-top: 30rpx;
		border-radius: 20rpx;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx;

		>text {
			color: #1F2937;
		}

		>image {
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			background-color: #f8f8f8;
			padding: 10rpx;
			box-sizing: border-box;
		}
	}

	>.list {
		background-color: #fff;
		border-radius: 20rpx;
		margin-top: 30rpx;
		padding: 0 30rpx;

		>view {
			height: 110rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			&+view {
				border-top: 1rpx solid #f8f8f8;
			}

			>text {
				color: #1F2937;
			}
		}
	}

	>.btn {
		margin: auto 0 40rpx;
	}
}
</style>
